package cn.jinjie.day03.test18;

import java.util.ArrayList;

public class Test {
    public static void main(String[] args) {
        Drink d1 = new Beer("青岛冰醇啤酒600ml", 3.5);
        Drink d2 = new Coffee("蓝山咖啡350ml", 199);
        ArrayList<Drink> list = new ArrayList<>();
        list.add(d1);
        list.add(d2);
        for (int i = 0; i < list.size(); i++) {
            if (list.get(i) instanceof Beer) {
                Beer beer = (Beer) list.get(i);
                beer.taste();
                System.out.println("优惠金额为:" + beer.lotto());
            }
            if (list.get(i) instanceof Coffee) {
                Coffee c = (Coffee) list.get(i);
                c.taste();
                System.out.println("优惠金额为:" + c.lotto());
            }
        }
    }
}
